<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<% String path = request.getContextPath(); %>
<link href="<%=path %>/css/video-js.min.css" rel="stylesheet">
<link rel="stylesheet" href="<%=path %>/js/themes/insdep/easyui.css"/>
<link rel="stylesheet" href="<%=path %>/js/themes/insdep/easyui_animation.css"/>
<link rel="stylesheet" href="<%=path %>/js/themes/insdep/insdep_theme_default.css">
<link rel="stylesheet" href="<%=path %>/js/themes/insdep/icon.css">
<script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=path %>/js/jquery.easyui-1.5.1.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/themes/insdep/jquery.insdep-extend.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<table id="brandOfficeMaster"></table>
	<div id="changemas"></div>
	<script type="text/javascript">
	$('#brandOfficeMaster').datagrid({          
	    url:"<%=request.getContextPath()%>/userController/queryBrandOfficeAndMaster.do",     
	    fitColumns:true,
	    striped:true,  
	    columns:[[                
	        {field:'brandOfficeName',title:'分店',width:100},    
	        {field:'employeeName',title:'店长',width:100},
	        {field:'opreation',title:'更改店长',width:100,
   			formatter: function(value,row,index){
					return '<a onclick="javascript:changeMaster('+row.brandOfficeId+')">指定店长</a>';
	        	}
	        },
	   ]]
	});  

	function changeMaster(brandOfficeId)
	{
		$('#changemas').dialog({    
		    title: 'Employee',    
		    width: 200,    
		    height: 200,    
		    href:"<%=path%>/userController/jumpToEmployeeList.do?brandOfficeId="+brandOfficeId,    
		    modal: true,
		    buttons:[{
				text:'保存',
				handler:function(){
					var newMasterid = $("[name='employeeId']:checked").val();
					$.ajax({
						url:"<%=path%>/userController/changeMaster.do",
						type:"post",
						data:{"newmasterid":newMasterid,"oldmasterid":oldmasterid},
						dataType:"text",
						async:false,
						success:function(result){
							if(result == "updateSuccess")
								{
									$('#changemas').dialog("close");
									$('#brandOfficeMaster').datagrid("reload");
								}
						},
						error:function(){
							alert(changeFail);
						}
					})
				}
			}]
		})
	}
		
	</script>
	</body>
</html>